home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / gtk-2.0 / gtk / gtkobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  7.7 KB  |  221 lines

  1. /* GTK - The GIMP Toolkit
  2.  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General Public
  15.  * License along with this library; if not, write to the
  16.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.  * Boston, MA 02111-1307, USA.
  18.  */
  19.  
  20. /*
  21.  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  22.  * file for a list of people on the GTK+ Team.  See the ChangeLog
  23.  * files for a list of changes.  These files are distributed with
  24.  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  25.  */
  26.  
  27. #ifndef __GTK_OBJECT_H__
  28. #define __GTK_OBJECT_H__
  29.  
  30.  
  31. #include <gtk/gtkenums.h>
  32. #include <gtk/gtktypeutils.h>
  33. #include <gtk/gtkdebug.h>
  34.  
  35. G_BEGIN_DECLS
  36.  
  37. /* macros for casting a pointer to a GtkObject or GtkObjectClass pointer,
  38.  * and to test whether `object' and `klass' are of type GTK_TYPE_OBJECT.
  39.  * these are the standard macros for all GtkObject-derived classes.
  40.  */
  41. #define    GTK_TYPE_OBJECT            (gtk_object_get_type ())
  42. #define GTK_OBJECT(object)        (GTK_CHECK_CAST ((object), GTK_TYPE_OBJECT, GtkObject))
  43. #define GTK_OBJECT_CLASS(klass)        (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_OBJECT, GtkObjectClass))
  44. #define GTK_IS_OBJECT(object)        (GTK_CHECK_TYPE ((object), GTK_TYPE_OBJECT))
  45. #define GTK_IS_OBJECT_CLASS(klass)    (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_OBJECT))
  46. #define    GTK_OBJECT_GET_CLASS(object)    (GTK_CHECK_GET_CLASS ((object), GTK_TYPE_OBJECT, GtkObjectClass))
  47.  
  48. /* Macros for extracting various fields from GtkObject and GtkObjectClass.
  49.  */
  50. #define GTK_OBJECT_TYPE(object)          (G_TYPE_FROM_INSTANCE (object))
  51. #define GTK_OBJECT_TYPE_NAME(object)      (g_type_name (GTK_OBJECT_TYPE (object)))
  52.  
  53. /* GtkObject only uses the first 4 bits of the flags field.
  54.  * Derived objects may use the remaining bits. Though this
  55.  * is a kinda nasty break up, it does make the size of
  56.  * derived objects smaller.
  57.  */
  58. typedef enum
  59. {
  60.   GTK_IN_DESTRUCTION    = 1 << 0, /* Used internally during dispose */
  61.   GTK_FLOATING        = 1 << 1,
  62.   GTK_RESERVED_1    = 1 << 2,
  63.   GTK_RESERVED_2    = 1 << 3
  64. } GtkObjectFlags;
  65.  
  66. /* Macros for extracting the object_flags from GtkObject.
  67.  */
  68. #define GTK_OBJECT_FLAGS(obj)          (GTK_OBJECT (obj)->flags)
  69. #define GTK_OBJECT_FLOATING(obj)      ((GTK_OBJECT_FLAGS (obj) & GTK_FLOATING) != 0)
  70.  
  71. /* Macros for setting and clearing bits in the object_flags field of GtkObject.
  72.  */
  73. #define GTK_OBJECT_SET_FLAGS(obj,flag)      G_STMT_START{ (GTK_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
  74. #define GTK_OBJECT_UNSET_FLAGS(obj,flag)  G_STMT_START{ (GTK_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
  75.  
  76. typedef struct _GtkObjectClass    GtkObjectClass;
  77.  
  78.  
  79. struct _GtkObject
  80. {
  81.   GObject parent_instance;
  82.   
  83.   /* 32 bits of flags. GtkObject only uses 4 of these bits and
  84.    *  GtkWidget uses the rest. This is done because structs are
  85.    *  aligned on 4 or 8 byte boundaries. If a new bitfield were
  86.    *  used in GtkWidget much space would be wasted.
  87.    */
  88.   guint32 flags;
  89. };
  90.  
  91. struct _GtkObjectClass
  92. {
  93.   GObjectClass parent_class;
  94.   
  95.   /* Non overridable class methods to set and get per class arguments */
  96.   void (*set_arg) (GtkObject *object,
  97.            GtkArg    *arg,
  98.            guint      arg_id);
  99.   void (*get_arg) (GtkObject *object,
  100.            GtkArg    *arg,
  101.            guint      arg_id);
  102.   
  103.   /* Default signal handler for the ::destroy signal, which is
  104.    *  invoked to request that references to the widget be dropped.
  105.    *  If an object class overrides destroy() in order to perform class
  106.    *  specific destruction then it must still invoke its superclass'
  107.    *  implementation of the method after it is finished with its
  108.    *  own cleanup. (See gtk_widget_real_destroy() for an example of
  109.    *  how to do this).
  110.    */
  111.   void (*destroy)  (GtkObject *object);
  112. };
  113.  
  114.  
  115.  
  116. /* Application-level methods */
  117.  
  118. GtkType    gtk_object_get_type        (void) G_GNUC_CONST;
  119.  
  120. void gtk_object_sink      (GtkObject *object);
  121. void gtk_object_destroy      (GtkObject *object);
  122.  
  123. /****************************************************************/
  124.  
  125. #ifndef GTK_DISABLE_DEPRECATED 
  126.  
  127. GtkObject*    gtk_object_new          (GtkType           type,
  128.                        const gchar          *first_property_name,
  129.                        ...);
  130. GtkObject*    gtk_object_ref          (GtkObject          *object);
  131. void        gtk_object_unref      (GtkObject          *object);
  132. void gtk_object_weakref      (GtkObject        *object,
  133.                GtkDestroyNotify  notify,
  134.                gpointer         data);
  135. void gtk_object_weakunref (GtkObject        *object,
  136.                GtkDestroyNotify  notify,
  137.                gpointer         data);
  138.  
  139. /* Set 'data' to the "object_data" field of the object. The
  140.  *  data is indexed by the "key". If there is already data
  141.  *  associated with "key" then the new data will replace it.
  142.  *  If 'data' is NULL then this call is equivalent to
  143.  *  'gtk_object_remove_data'.
  144.  *  The gtk_object_set_data_full variant acts just the same,
  145.  *  but takes an additional argument which is a function to
  146.  *  be called when the data is removed.
  147.  *  `gtk_object_remove_data' is equivalent to the above,
  148.  *  where 'data' is NULL
  149.  *  `gtk_object_get_data' gets the data associated with "key".
  150.  */
  151. void     gtk_object_set_data         (GtkObject         *object,
  152.                       const gchar    *key,
  153.                       gpointer          data);
  154. void     gtk_object_set_data_full    (GtkObject         *object,
  155.                       const gchar    *key,
  156.                       gpointer          data,
  157.                       GtkDestroyNotify destroy);
  158. void     gtk_object_remove_data         (GtkObject         *object,
  159.                       const gchar    *key);
  160. gpointer gtk_object_get_data         (GtkObject         *object,
  161.                       const gchar    *key);
  162. void     gtk_object_remove_no_notify (GtkObject         *object,
  163.                       const gchar    *key);
  164.  
  165. /* Set/get the "user_data" object data field of "object". It should
  166.  *  be noted that these functions are no different than calling
  167.  *  `gtk_object_set_data'/`gtk_object_get_data' with a key of "user_data".
  168.  *  They are merely provided as a convenience.
  169.  */
  170. void     gtk_object_set_user_data (GtkObject    *object,
  171.                    gpointer     data);
  172. gpointer gtk_object_get_user_data (GtkObject    *object);
  173.  
  174.  
  175. /* Object-level methods */
  176.  
  177. /* Object data method variants that operate on key ids. */
  178. void gtk_object_set_data_by_id        (GtkObject     *object,
  179.                      GQuark          data_id,
  180.                      gpointer      data);
  181. void gtk_object_set_data_by_id_full    (GtkObject     *object,
  182.                      GQuark          data_id,
  183.                      gpointer      data,
  184.                      GtkDestroyNotify destroy);
  185. gpointer gtk_object_get_data_by_id    (GtkObject     *object,
  186.                      GQuark          data_id);
  187. void  gtk_object_remove_data_by_id    (GtkObject     *object,
  188.                      GQuark          data_id);
  189. void  gtk_object_remove_no_notify_by_id    (GtkObject     *object,
  190.                      GQuark          key_id);
  191. #define    gtk_object_data_try_key        g_quark_try_string
  192. #define    gtk_object_data_force_id    g_quark_from_string
  193.  
  194. /* GtkArg flag bits for gtk_object_add_arg_type
  195.  */
  196. typedef enum
  197. {
  198.   GTK_ARG_READABLE     = G_PARAM_READABLE,
  199.   GTK_ARG_WRITABLE     = G_PARAM_WRITABLE,
  200.   GTK_ARG_CONSTRUCT     = G_PARAM_CONSTRUCT,
  201.   GTK_ARG_CONSTRUCT_ONLY = G_PARAM_CONSTRUCT_ONLY,
  202.   GTK_ARG_CHILD_ARG     = 1 << 4
  203. } GtkArgFlags;
  204. #define    GTK_ARG_READWRITE    (GTK_ARG_READABLE | GTK_ARG_WRITABLE)
  205. void    gtk_object_get        (GtkObject    *object,
  206.                  const gchar    *first_property_name,
  207.                  ...) G_GNUC_NULL_TERMINATED;
  208. void    gtk_object_set        (GtkObject    *object,
  209.                  const gchar    *first_property_name,
  210.                  ...) G_GNUC_NULL_TERMINATED;
  211. void    gtk_object_add_arg_type        (const gchar    *arg_name,
  212.                      GtkType     arg_type,
  213.                      guint         arg_flags,
  214.                      guint         arg_id);
  215.  
  216. #endif /* GTK_DISABLE_DEPRECATED */
  217.  
  218. G_END_DECLS
  219.  
  220. #endif /* __GTK_OBJECT_H__ */
  221.